package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.UserDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller/*标识当前类为控制器类,用于接收控制器请求*/
public class UserController {
    /*RequestMapping注解:请求注解,根据请求的地址映射到对应的控制器方法*/
    /*ResponseBody注解: 1.允许控制器以返回值形式返回数据给客户端*/
    /*客户端传递用户名和密码*/
    @RequestMapping("/v1/users/login")
    @ResponseBody
    /*登录功能*/
    public String login(){
        return "登陆成功";

    }
    /*注册
    * 1.*/
    @RequestMapping("/v1/users/reg1")
    @ResponseBody
    public String reg1(HttpServletRequest request){
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        return username+"___"+password;
    }

    @RequestMapping("/v1/users/reg2")
    @ResponseBody
    public String reg2(String username ,String password){
        return username+"___"+password;
    }
    @RequestMapping("/v1/users/reg3")
    @ResponseBody
    public String reg3(UserDTO userDTO){
        String username = userDTO.getUsername();
        String password = userDTO.getPassword();
        return username+"__++"+password;}
}
